package com.tjec.project.mdmSynchronous.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tjec.framework.aspectj.lang.annotation.Log;
import com.tjec.framework.aspectj.lang.enums.BusinessType;
import com.tjec.project.mdmSynchronous.domain.BmsProjectLeader;
import com.tjec.project.mdmSynchronous.service.IBmsProjectLeaderService;
import com.tjec.framework.web.controller.BaseController;
import com.tjec.framework.web.domain.AjaxResult;
import com.tjec.common.utils.poi.ExcelUtil;
import com.tjec.framework.web.page.TableDataInfo;

/**
 * 项目负责人Controller
 * 
 * @author villwang
 * @date 2020-05-25
 */
@RestController
@RequestMapping("/system/projectLeader")
public class BmsProjectLeaderController extends BaseController
{
    @Autowired
    private IBmsProjectLeaderService bmsProjectLeaderService;

    /**
     * 查询项目负责人列表
     */
//    @PreAuthorize("@ss.hasPermi('system:projectLeader:list')")
    @GetMapping("/list")
    public TableDataInfo list(BmsProjectLeader bmsProjectLeader)
    {
        startPage();
        List<BmsProjectLeader> list = bmsProjectLeaderService.selectBmsProjectLeaderList(bmsProjectLeader);
        return getDataTable(list);
    }

    /**
     * 导出项目负责人列表
     */
//    @PreAuthorize("@ss.hasPermi('system:projectLeader:export')")
    @Log(title = "项目负责人", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BmsProjectLeader bmsProjectLeader)
    {
        List<BmsProjectLeader> list = bmsProjectLeaderService.selectBmsProjectLeaderList(bmsProjectLeader);
        ExcelUtil<BmsProjectLeader> util = new ExcelUtil<BmsProjectLeader>(BmsProjectLeader.class);
        return util.exportExcel(list, "projectLeader");
    }

    /**
     * 获取项目负责人详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:projectLeader:query')")
    @GetMapping(value = "/{guid}")
    public AjaxResult getInfo(@PathVariable("guid") String guid)
    {
        return AjaxResult.success(bmsProjectLeaderService.selectBmsProjectLeaderByGuid(guid));
    }

    /**
     * 新增项目负责人
     */
//    @PreAuthorize("@ss.hasPermi('system:projectLeader:add')")
    @Log(title = "项目负责人", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BmsProjectLeader bmsProjectLeader)
    {
        return toAjax(bmsProjectLeaderService.insertBmsProjectLeader(bmsProjectLeader));
    }

    /**
     * 修改项目负责人
     */
//    @PreAuthorize("@ss.hasPermi('system:projectLeader:edit')")
    @Log(title = "项目负责人", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BmsProjectLeader bmsProjectLeader)
    {
        return toAjax(bmsProjectLeaderService.updateBmsProjectLeader(bmsProjectLeader));
    }

    /**
     * 删除项目负责人
     */
//    @PreAuthorize("@ss.hasPermi('system:projectLeader:remove')")
    @Log(title = "项目负责人", businessType = BusinessType.DELETE)
	@DeleteMapping("/{guids}")
    public AjaxResult remove(@PathVariable String[] guids)
    {
        return toAjax(bmsProjectLeaderService.deleteBmsProjectLeaderByGuids(guids));
    }
}
